﻿/******************************************************************************
 * GImageTypes.cs
 * 
 * This module implements the DataContract types needed to query Google Images
 * 
 * Date:   12/2008
 * 
 * Copyright (c) 2009, 2010, Mark Betz 
 * 
 * All rights reserved. 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met: 
 * 
 *   * Redistributions of source code must retain the above copyright 
 *     notice, this list of conditions and the following disclaimer. 
 *   * Redistributions in binary form must reproduce the above copyright 
 *     notice, this list of conditions and the following disclaimer in the 
 *     documentation and/or other materials provided with the distribution. 
 *   * Neither the name of the Author nor the names of contributors may be 
 *     used to endorse or promote products derived from this software
 *     without specific prior written permission. 
 *     
 * THIS SOFTWARE IS PROVIDED BY MARK BETZ ''AS IS'' AND ANY  EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL MARK BETZ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 * 
 */
using System.Runtime.Serialization;

namespace GSearch
{
    /// <summary>
    /// Implements the image-specific portion of the Google results json
    /// object
    /// </summary>
    [DataContract]
    public class GImageResults : GResults
    {
        /// <summary>
        /// A System.String containing a title or caption for the image
        /// search result. May contain HTML formatting.
        /// </summary>
        [DataMember(Name = "title")]
        public string Title { get; set; }

        /// <summary>
        /// A System.String containing a title or caption for the image,
        /// without any HTML formatting.
        /// </summary>
        [DataMember(Name = "titleNoFormatting")]
        public string TitleNoFormatting { get; set; }

        /// <summary>
        /// A System.String containing the URL address of the original image
        /// without escape characters.
        /// </summary>
        [DataMember(Name = "unescapedUrl")]
        public string UnescapedUrl { get; set; }

        /// <summary>
        /// A System.String containing the URL address of the original image
        /// with escape characters.
        /// </summary>
        [DataMember(Name = "url")]
        public string Url { get; set; }

        /// <summary>
        /// A System.String containing a display version of the URL to the
        /// original image.
        /// </summary>
        [DataMember(Name = "visibleUrl")]
        public string VisibleUrl { get; set; }

        /// <summary>
        /// A System.String containing the URL address of the page in which
        /// the image originally appeared.
        /// </summary>
        [DataMember(Name = "originalContextUrl")]
        public string OriginalContextUrl { get; set; }
        
        /// <summary>
        /// A System.Int32 containing the width of the original image in
        /// pixels.
        /// </summary>
        [DataMember(Name = "width")]
        public int Width { get; set; }

        /// <summary>
        /// A System.Int32 containing the height of the original image in
        /// pixels.
        /// </summary>
        [DataMember(Name = "height")]
        public int Height { get; set; }

        /// <summary>
        /// A System.Int32 containing the width of the thumbnail image in
        /// pixels.
        /// </summary>
        [DataMember(Name = "tbWidth")]
        public int TbWidth { get; set; }

        /// <summary>
        /// A System.Int32 containing the height of the thumbnail image in
        /// pixels.
        /// </summary>
        [DataMember(Name = "tbHeight")]
        public int TbHeight { get; set; }

        /// <summary>
        /// A System.String containing the URL address of a thumbnail
        /// representation of the image.
        /// </summary>
        [DataMember(Name = "tbUrl")]
        public string TbUrl { get; set; }
        
        /// <summary>
        /// A System.String containing an HTML-formatted snippet of content
        /// associated with the image.
        /// </summary>
        [DataMember(Name = "content")]
        public string Content { get; set; }
        
        /// <summary>
        /// A System.String containing an text-formatted snippet of content
        /// associated with the image.
        /// </summary>
        [DataMember(Name = "contentNoFormatting")]
        public string ContentNoFormatting { get; set; }
    }

    /// <summary>
    /// Implements the image-specific portion of the Google responseData json
    /// object
    /// </summary>
    [DataContract]
    public class GImageResponseData : GResponseData
    {
        /// <summary>
        /// Returns an array of <see cref="GSearch.GImageResults"/> objects
        /// containing the results of a search.
        /// </summary>
        [DataMember(Name = "results")]
        public GImageResults[] Results { get; set; }
    }

    /// <summary>
    /// Implements the image-specific portion of the Google response json object
    /// </summary>
    [DataContract]
    public class GImageResponse : GResponse
    {
        /// <summary>
        /// An instance of <see cref="GSearch.GImageResponseData"/> containing
        /// the results of a search.
        /// </summary>
        [DataMember(Name = "responseData")]
        public GImageResponseData Response { get; set; }
    }
}